<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 200px;
            height: 200px;
            background: orange;
        }
    </style>
</head>

<body>

    <div id="app">

        <!-- .self -->
        <!-- 执行事件触发自身的回调 -->
        <div @click.self="clickBox" class="box">
            <button @click="clickBtn">按钮</button>
        </div>

        <!-- .stop -->
        <!-- 阻止事件冒泡 -->
        <!-- <div @click="clickBox" class="box">
            <button  @click.stop="clickBtn" >按钮</button>
        </div> -->

        <!-- .prevent -->
        <!-- 阻止默认行为 -->
        <!-- <a href="https://www.baidu.com/" @click.prevent="push">内容</a> -->


        <!-- once -->
        <!-- 只执行一次事件 -->
        <!-- <button  @click.once="onceClick" >按钮</button> -->

        <!-- capture -->
        <!-- 添加事件监听器时使用事件捕获模式 -->
        <!-- <div @click.capture="clickBox" class="box">
            <button @click="clickBtn">按钮</button>
        </div> -->

        
        <!-- passive -->
    </div>

    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script>

        new Vue({
            // 元素
            el: "#app",
            // 定义的数据(状态)
            data: {

            },
            methods: {
                clickBox() {
                    console.log('点击了盒子')
                },
                clickBtn() {
                    console.log('点击了按钮')
                },
                // 跳转
                push() {
                    console.log('点了a标签')
                },
                onceClick() {
                    console.log('执行了事件')
                }
            }
        })
    </script>
</body>

</html>